/*
 * This file is part of Viper.  Viper is free software: you can
 * redistribute it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation, version 2.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 51
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Copyright GruntXProductions
 */

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.IO;
using System.Text;

namespace Viper
{
    public class VirtualMachine
	{
		public uint StackPointer;
		public uint BasePointer;
		private byte[] RAM;
		private uint IP = 0;
		public VirtualMachine(Assembly program)
		{
			RAM = new byte[0xFFFF];
			uint p = 0; 
			BasePointer = 0xFFFF - 1024;
			foreach(Instruction instr in program.innerCode)
			{
				foreach(byte b in instr.Bytecode)
				{
					RAM[p] = b;
					p++;
				}
			}
		}
		public  unsafe void Invoke(uint address)
		{
			IP = address;
			fixed(byte* ram = RAM) 
			{
				while(true)	
				{
					byte opcode = ram[IP];
					byte arglength = ram[IP++];
				
				}
			}
		}
	}
}
